<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        img{
            width: 50px;
            height: 50px;
            position: absolute;
        }

    </style>
</head>
<body>

    <img src="../images/6.jpg" alt="">

    <script>

        // 鼠标跟随
        var oImg = document.querySelector('img') ;

        document.onmousemove = function(e) {
            var e = e || event ;
            var x = e.x ;
            var y = e.y ;
            oImg.style.left = x + 'px' ;
            oImg.style.top = y + 'px' ;
        }

    </script>
    
</body>
</html>